package systems
{
	import flash.events.Event;
	
	/**
	 * @author Humberto Anjos
	 */
	public class Enemies
	{
		private var MAX_ENEMY_DELAY = 20
		private var enemyDelay:int = MAX_ENEMY_DELAY
		
		private var _main:Main
		
		public function Enemies(main:Main) 
		{
			_main = main
		}
		
		public function update() 
		{
			enemyDelay--
			
			if (enemyDelay <= 0) {
				_main.world.newEnemy(
					(Math.random() >= 0.5) ? States.PURPLE : States.RED, 
					Math.random() * _main.stage.stageWidth, 
					-50)
				enemyDelay = MAX_ENEMY_DELAY
			}
			
			//removeOutsideEnemies();
		}
		
		/*private function enemyIsNotOnStage(enemy:Enemy):Boolean 
		{
			return enemy.x < 0 || enemy.x > main.stage.stageWidth 
				|| enemy.y > main.stage.stageHeight + enemy.height
		}
		
		private function removeOutsideEnemies():void 
		{
			var enemyIndexesToRemove = []
			for (var i = 0; i < enemies.length; i++ ) {
				if (enemyIsNotOnStage(enemies[i])) {
					enemyIndexesToRemove.push(i)
				}
			}
			
			for (var j = enemyIndexesToRemove.length - 1; j >= 0; j--) {
				enemies.splice(j, 1)
			}
		}*/
	}

}